<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>参数配置</title>
	<link rel="stylesheet" type="text/css" href="../css/style.css">
	<link rel="stylesheet" type="text/css" href="../js/layer/theme/default/layer.css">
	<link href="../images/favicon.ico" rel="icon" type="image/x-icon" />
	<!-- <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script> -->
	<script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../js/layer/layer.js"></script>
	<script type="text/javascript" src="../js/config.js"></script>
	
	<script type="text/javascript" src="../js/vue.js"></script>
	<script type="text/javascript" src="../js/filter.js"></script>
	<style>
		.tab .tab_menu ul li.on{
			background: #999;
		}
		.tab .tab_box > div{
			display: none;
		}
		.tab .tab_box > div:first-child{
			display: block;
		}
		#addParamForm > .cell{
			display: none;
		}
		#addParamForm > .cell:first-child{
			display: block;
		}
	</style>
</head>
<body>
	<div class="header">
		<img src="../images/logo.png">
		<p>欢迎您，<span id="userName">123</span><a onclick="logout()">退出登录</a></p>
	</div>
  <div class="tab" style="padding-top: 20px;" id="crmSysParamList">
	  <div class="tab_menu" >
		  <ul>
			  <a class="add-button on" v-if="resourceList.indexOf('渠道配置') != -1" data-code="channelId">渠道配置</a>
			  <a class="add-button" v-if="resourceList.indexOf('质保等级设置') != -1" data-code="warrantyId">质保等级配置</a>
			  <a class="add-button" v-if="resourceList.indexOf('客户等级配置') != -1" data-code="customerLevelId">客户等级配置</a>
			  <a class="add-button" v-if="resourceList.indexOf('保险公司配置') != -1" data-code="insuranceId">保险公司配置</a>
			  <a class="add-button" v-if="resourceList.indexOf('按揭公司配置') != -1" data-code="mortgageId">按揭公司配置</a>
			  <a class="add-button" href="index.html">返回首页</a>
		  </ul>
	  </div>
	  <div class="cell">
		  <a onclick="newParamConf()" class="add-button" style="margin-right: 20px;background-color: #666" id="addBtn">新增</a>
	  </div>
	  <div class="tab_box" >
		  <div v-if="resourceList.indexOf('渠道配置') != -1">
			  <table class="list-box">
				  <tr>
					  <th>渠道名称</th>
					  <th>备注</th>
					  <th>创建时间</th>
					  <th>操作</th>
				  </tr>
				  <tr  v-for="(channel,index) in res.channelList">
					  <td>{{channel.channelName}}</td>
					  <td>{{channel.channelRemark}}</td>
					  <td>{{channel.channelCreateTime | filterGetDate}}</td>
					  <td>
						  <span v-bind:data-index="index" data-code="channel"   onclick="updateInfo(this)" class="over-small">编辑</span>
					  </td>
				  </tr>
			  </table>
		  </div>
		  <div v-if="resourceList.indexOf('质保等级设置') != -1">
			  <table class="list-box">
				  <tr>
					  <th>质保等级名称</th>
					  <th>质保费用</th>
					  <th>创建时间</th>
					  <th>操作</th>
				  </tr>
				  <tr v-for="(warranty,index) in res.warrantyList">
					  <td>{{warranty.warrantyName}}</td>
					  <td>{{warranty.warrantyFeeCent}}</td>
					  <td>{{warranty.warrantyCreateTime | filterGetDate}}</td>
					  <td>
						  <span v-bind:data-index="index" data-code="warranty"  onclick="updateInfo(this)" class="over-small">编辑</span>
					  </td>
				  </tr>
			  </table>
		  </div>
		  <div v-if="resourceList.indexOf('客户等级配置') != -1">
			  <table class="list-box">
				  <tr>
					  <th>客户等级</th>
					  <th>最大跟进天数</th>
					  <th>创建时间</th>
					  <th>操作</th>
				  </tr>
				  <tr v-for="(customerLevel,index) in  res.customerLeveList">
					  <td>{{customerLevel.levelTxt}}</td>
					  <td>{{customerLevel.maxFollowDay}}</td>
					  <td>{{customerLevel.levelCreateTime}}</td>
					  <td>
						  <span v-bind:data-index="index" data-code="customerLevel"  onclick="updateInfo(this)" class="over-small">编辑</span>
					  </td>
				  </tr>
			  </table>
		  </div>
		  <div v-if="resourceList.indexOf('保险公司配置') != -1">
			  <table class="list-box">
				  <tr>
					  <th>保险公司名称</th>
					  <th>创建时间</th>
					  <th>操作</th>
				  </tr>
				  <tr v-for="(insurance,index) in  res.insuranceList">
					  <td>{{insurance.insuranceName}}</td>
					  <td>{{insurance.insuranceCreateTime}}</td>
					  <td>
						  <span v-bind:data-index="index" data-code="insurance"  onclick="updateInfo(this)" class="over-small">编辑</span>
					  </td>
				  </tr>
			  </table>
		  </div>
		  <div v-if="resourceList.indexOf('按揭公司配置') != -1">
			  <table class="list-box">
				  <tr>
					  <th>按揭公司名称</th>
					  <th>创建时间</th>
					  <th>操作</th>
				  </tr>
				  <tr v-for="(mortgage,index)  in res.mortgageList">
					  <td>{{mortgage.mortgageName}}</td>
					  <td>{{mortgage.mortgageCreateTime | filterGetDate}}</td>
					  <td>
						  <span v-bind:data-index="index" data-code="mortgage"  onclick="updateInfo(this)" class="over-small">编辑</span>
					  </td>
				  </tr>
			  </table>
		  </div>
	  </div>
  </div>



	<div class="cell-content" id="addParamForm" style="display: none;">
		<form id="channelId" class="cell">
			<input type="hidden" name="channelId" v-model="channel.channelId">
			<label><span class="red">*</span>渠道名称</label>
			<input type="text" name="channelName" required v-model="channel.channelName">
			<label>状态</label>
			<div class="group-radio"><input name="channelState" v-model="channel.channelState" type="radio" value="1" />有效</div>
			<div class="group-radio"><input name="channelState" v-model="channel.channelState" type="radio" value="0" />无效</div>
			<div>
				<label style="float:left;">备注</label>
				<textarea  name="channelRemark" v-model="channel.channelRemark"></textarea>
			</div>
		</form>

		<form id="warrantyId" class="cell">
			<input type="hidden" name="warrantyId" v-model="warranty.warrantyId">
			<label><span class="red">*</span>质保等级</label>
			<input type="text" name="warrantyName" required v-model="warranty.warrantyName">
			<label><span class="red">*</span>质保费用</label>
			<input type="text" name="warrantyFeeCent" required v-model="warranty.warrantyFeeCent">
			<label>状态</label>
			<div class="group-radio"><input name="warrantyState" v-model="warranty.warrantyState" type="radio" value="1" />有效</div>
			<div class="group-radio"><input name="warrantyState" v-model="warranty.warrantyState" type="radio" value="0" />无效</div>
			<div>
				<label style="float:left;">备注</label>
				<textarea  name="warrantyRemark" v-model="warranty.warrantyRemark"></textarea>
			</div>
		</form>

		<form id="customerLevelId"  class="cell">
			<input type="hidden" name="levelId" v-model="customerLevel.levelId">
			<label><span class="red">*</span>客户等级</label>
			<input type="text" name="levelTxt" required v-model="customerLevel.levelTxt">
			<label><span class="red">*</span>最大跟踪天数</label>
			<input type="text" name="maxFollowDay" required v-model="customerLevel.maxFollowDay">
			<label>状态</label>
			<div class="group-radio"><input name="levelState" v-model="customerLevel.levelState" type="radio" value="1" />有效</div>
			<div class="group-radio"><input name="levelState" v-model="customerLevel.levelState" type="radio" value="0" />无效</div>
		</form>

		<form id="insuranceId" class="cell">
			<input type="hidden" name="insuranceId" v-model="insurance.insuranceId">
			<label><span class="red">*</span>保险公司名称</label>
			<input type="text" name="insuranceName" required v-model="insurance.insuranceName">
			<br>
			<label>状态</label>
			<div class="group-radio"><input name="insuranceState" v-model="insurance.insuranceState" type="radio" value="1" />有效</div>
			<div class="group-radio"><input name="insuranceState" v-model="insurance.insuranceState" type="radio" value="0" />无效</div>
		</form>

		<form id="mortgageId" class="cell">
			<input type="hidden" name="mortgageId" v-model="mortgage.mortgageId">
			<label><span class="red">*</span>按揭公司名称</label>
			<input type="text" name="mortgageName" required v-model="mortgage.mortgageName">
			<br>
			<label>状态</label>
			<div class="group-radio"><input name="mortgageState" v-model="mortgage.mortgageState" type="radio" value="1" />有效</div>
			<div class="group-radio"><input name="mortgageState" v-model="mortgage.mortgageState" type="radio" value="0" />无效</div>
		</form>


	</div>
	
  <script type="text/javascript">
      var crmSysParamList = new Vue({
          el:'#crmSysParamList',
          data: {
              res:[],
              resourceList:[],
          },
          methods: {
          }
      });
      var crmSysParamForm = new Vue({
          el:'#addParamForm',
          data: {
              channel:{},
			  warranty:{},
              customerLevel:{},
              insurance:{},
              mortgage:{}
          },
          methods: {
          }
      });



      // var crmAccountNav = new Vue({
      // 	el:'#accountNav',
      // 	data:{
      // 		resourceList:[],
      // 	}
      // });
      var crmAccount =  JSON.parse(sessionStorage.getItem('crmAccount'));
      var accountList = crmAccount.resourceList;
      $('#userName').html(crmAccount.accountName)
      var accountNav = [];

		for (var i = 0; i < accountList.length; i++) {
			accountNav.push(accountList[i].resourceName);
			for (var j = 0; j < accountList[i].resources.length; j++) {
				accountNav.push(accountList[i].resources[j].resourceName);
			}
		}
		crmSysParamList.resourceList = accountNav;



      $(function(){
          $("#addBtn").attr('onclick','newParamConf("/channel-insert","channelId")');
          $(document).on('click','.tab_menu ul a',function(){
          	$(this).addClass("on").siblings().removeClass("on"); //切换选中的按钮高亮状态
              var index=$(this).index(); //获取被按下按钮的索引值，需要注意index是从0开始的
              var code = $(this).attr('data-code');
              $("#addParamForm > .cell").hide();
			  if (code == 'channelId'){
                  $("#addBtn").attr('onclick','newParamConf("/channel-insert","channelId")')
                  $('#channelId').show();
			  }
			  else if (code == 'warrantyId') {
                  $("#addBtn").attr('onclick','newParamConf("/warranty-insert","warrantyId")');
                  $('#warrantyId').show();
			  }
              else if (code == 'customerLevelId') {
                  $("#addBtn").attr('onclick','newParamConf("/customerLevel-insert","customerLevelId")')
                  $('#customerLevelId').show();
              }
              else if (code == 'insuranceId') {
                  $("#addBtn").attr('onclick','newParamConf("/insurance-insert", "insuranceId")')
                  $('#insuranceId').show();
              }
              else if (code == 'mortgageId') {
                  $("#addBtn").attr('onclick','newParamConf("/mortgage-insert","mortgageId")')
                  $('#mortgageId').show();
              }
              $(".tab_box > div").eq(index).show().siblings().hide(); //在按钮选中时在下面显示相应的内容，同时隐藏不需要的框架内容
              // $("#addParamForm > .cell").eq(index).show().siblings().hide(); 
          })
        
      });

  </script>
  <script type="text/javascript" src="../js/sys_param_conf.js"></script>

</body>
</html>
